const user = {
	state: {
		//未读消息数，包含系统消息，通讯录消息
		messageCount: 0,
		accesstoken: '',
		refeshtoken: '',
		userInfo: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo') : {},
		Dict: {}, //字典
		hasLogin: uni.getStorageSync('hasLogin') ? uni.getStorageSync('hasLogin') : false,
	},
	mutations: {
		//消息数量
		SET_MESSAGE_COUNT: (state, count) => {
			state.messageCount = count
		},
		// 更新登录状态
		UPDATE_LOGIN_STATUS: (state, bool) => {
			state.hasLogin = bool;
			uni.setStorageSync('hasLogin', bool);
		},
		// 设置token
		SET_TOKEN: (state, token) => {
			state.accesstoken = token.a_token;
			state.refeshtoken = token.r_token;
			uni.setStorageSync("token", {
				accesstoken: token.a_token,
				refeshtoken: token.r_token
			})
		},
		// 设置用户资料
		SET_USERINFO: (state, userInfo) => {
			state.userInfo = userInfo;
			uni.setStorageSync("userInfo", userInfo)
		},
		// 设置字典值
		SET_DICT: (state, Dict) => {
			state.Dict = Dict;
			uni.setStorageSync("Dict", Dict)

		},
		// 清除登录信息
		REMOVE_LOGIN: (state) => {
			state.accesstoken = '';
			state.refeshtoken = '';
			state.userInfo = {};
			state.hasLogin = false;
			uni.setStorageSync('hasLogin', false);
			uni.removeStorageSync('token');
			uni.removeStorageSync('userInfo');

		},
	},
	actions: {}
}


export default user;
